<!-- Dom模板 -->
<template>
  <div class="orderMain">
    <!-- 订单 == Dom内容 -->
    <!-- "state":1, // 1待支付 2已支付 3已关闭 4已退款 -->
    <div class="orderDiv">订单</div>
    <div class="chooseDiv">
      <div class="shaiX">订单筛选</div>
      <div class="formDiv">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="订单状态" style="display: flex">
            <el-select v-model="form.region" placeholder="请选择">
              <el-option label="待支付" value="1"></el-option>
              <el-option label="已支付" value="2"></el-option>
              <el-option label="已关闭" value="3"></el-option>
              <el-option label="已退款" value="4"></el-option>
            </el-select>
          </el-form-item>
          <!-- 时间选择器 -->
          <div class="block">
            <span>提交时间</span>
            <el-date-picker
              v-model="value2"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            >
            </el-date-picker>
          </div>
          <el-form-item label="" class="messageDiv">
            <el-input
              v-model="form.name"
              placeholder="请输入订单号、用户账号、昵称"
            ></el-input>
          </el-form-item>
          <div class="chooseButtonDiv">
            <button>筛选</button>
          </div>
        </el-form>
      </div>
      <div></div>
    </div>
    <!-- 下面内容 -->
    <div class="btmDiv">
      <p class="titleP shaiX">订单列表</p>
      <el-table :data="dataList" style="width: 100%">
        <el-table-column prop="" label="">
          <template slot-scope="scope">
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">
                <!-- <div class="operatorDiv"> -->
                <input type="checkbox" v-model="scope.row.checked" />
                <!-- </div> -->
              </el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="orNum" label="订单编号"> </el-table-column>
        <el-table-column prop="heir" label="用户昵称"> </el-table-column>
        <el-table-column prop="order" label="手机号"> </el-table-column>
        <el-table-column prop="name" label="课程名称"> </el-table-column>
        <el-table-column prop="price" label="订单金额"> </el-table-column>
        <el-table-column prop="" label="订单状态">
          <template slot-scope="scope">
            <!-- {{scope.row.states}} -->
            {{
              scope.row.states === 1
                ? "已支付"
                : scope.row.states === 2
                ? "待退款"
                : scope.row.states === 3
                ? "已退款"
                : scope.row.states === 4
                ? "未退款"
                : ""
            }}
          </template>
        </el-table-column>
        <el-table-column prop="ubloadTime" label="提交时间"> </el-table-column>
        <el-table-column prop="operator" label="操作">
          <template slot-scope="scope">
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">
                <div class="operatorDiv">
                  <template>
                    <span
                      v-for="item in scope.row.operator"
                      :key="item.id"
                      :style="
                        item === '删除'
                          ? 'color:red'
                          : item === '查看'
                          ? 'color:green'
                          : 'color:black'
                      "
                      @click="stateClick(item, scope.row.id)"
                      >{{ item }}</span
                    >
                  </template>
                </div>
              </el-tag>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="checkAllDiv">
      <span class="demonstration">
        <input type="checkbox" v-model="checkAll" /> 全选</span
      >
      <!-- :current-page="1"  默认当前页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="1"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="gatlunboLogin"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
// import a from './a'; // 引入组件
// import * as api from "../../../api/getSomeList";

export default {
  name: "",
  data() {
    return {
      dataList: [], // 列表
      pickerOptions: {
        // 时间
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      value1: "",
      value2: "",
      // 表单 筛选..
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      //
      // currentPage4: 4,
      // 总共多少条
      gatlunboLogin: 0,
      // curPage当前页  size每页条数
      curPage: 1,
      size: 5,
      oldTime: "",
      newTime: "",
    };
  },
  // 计算属性
  computed: {
    // 全选
    checkAll: {
      get() {
        return this.dataList.every((item) => {
          return item.checked;
        });
      },
      set(val) {
        this.dataList.forEach((item) => {
          item.checked = val;
        });
      },
    },
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  // Vue方法定义
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style>
.el-date-editor .el-range-separator {
  padding: 0;
}
.el-date-editor .el-range__close-icon {
  display: none;
}
.el-date-editor--daterange.el-input__inner {
  width: 300px;
}

.el-form-item__content {
  margin: 0 !important;
}
.el-table td,
.el-table th {
  text-align: center;
}
.el-table .cell {
  padding-left: 0;
  padding-right: 0;
}
</style>

<style scoped>
/* @import url(''); 引入css类 */
.formDiv .el-form {
  display: flex;
  align-items: center;
  justify-content: space-around;
  /* margin-bottom: 20px; */
}
.el-form-item {
  margin: 0 5px;
  margin-bottom: 0;
}
.el-form-item__content {
  margin-left: 0;
  margin-right: 20px;
}
.messageDiv {
  width: 300px;
}
.chooseDiv {
  margin-bottom: 20px;
  background-color: #fff;
  padding: 20px;
}
.orderDiv {
  padding: 20px 0 30px;
}
.block {
  display: flex;
  width: 380px;
  align-items: center;
}
.block span {
  display: inline-block;
  margin-right: 4px;
}

.chooseButtonDiv button {
  font-size: 14px;
  color: #fff;
  background-color: #38a189;
  border: 1px solid #38a189;
  border-radius: 2px;
  padding: 0px 20px;
  cursor: pointer;
  height: 36px;
  line-height: 36px;
}
.operatorDiv span {
  display: inline-block;
  margin: 2px 6px;
  cursor: pointer;
}

.shaiX {
  padding: 10px 0;
  font-weight: bold;
}
.btmDiv {
  padding: 10px 0;
  background-color: #fff;
  max-height: 59vh;
  overflow-y: auto;
}
.titleP {
  padding: 20px 10px;
  background-color: #fff;
  border-bottom: 1px solid #ebeef5;
}

.el-table--fit {
  padding: 10px;
}
.el-tag {
  border: 0;
  border-color: #fff;
  background-color: #fff;
}
.checkAllDiv {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  background-color: #fff;
}
</style>